<template>
    <div>
    <h1>登录页面</h1>
    <table class="table table-bordered">
        <tbody>
            <tr>
            <td>用户名</td>
            <td><input type="text" v-model="queryinfo.userName" /></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password"  v-model="queryinfo.password"/></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="button" value="登录" class="btn btn-primary" @click="login" /></td>
        </tr>
        
        </tbody>
    </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import {ref, reactive } from 'vue';
import { useRouter, useRoute} from 'vue-router';
const route = useRoute();
const router = useRouter();

    let queryinfo=reactive({
        userName:'',
        password:'',
    });
    const login=()=>{
        axios({
            url:'',//请求的地址(路由)
            method:'get',//请求方式
            params:queryinfo,
        })
        .then((res)=>{
            console.log(res);
            if(res.data==-1){
            alert('用户名不存在');
            return;
            }
            else if(res.data==-2){
                alert('密码错误');
                return;
            }
            else{
                alert('登录成功');
            }

        })
        .catch((err)=>{
            console.log(err);
        })
        
    }
</script>

<style scoped>

</style>